package com.zhengbing.tj.common;

/**
 * 公共自定义异常类
 * 继承RuntimeException实现项目统一的异常处理机制，支持错误码和错误信息
 * 用于业务逻辑异常、参数校验失败、权限不足等场景的标准化异常抛出
 * 
 * @author zhengbing
 * @date 2025-07-07
 */
public class TjException extends RuntimeException {

    public static final int DEFAULT_ERROR_CODE = 500;

    private final int code;
    private final String message;

    public TjException(String message) {
        super(message);
        this.code = DEFAULT_ERROR_CODE;
        this.message = message;
    }

    public TjException(int code, String message) {
        super(message);
        this.code = code;
        this.message = message;
    }

    public int getCode() {
        return code;
    }

    @Override
    public String getMessage() {
        return message;
    }
}